/* Copyright (c) 2024 Huawei Technologies Co., Ltd.
 * This file is a part of the CANN Open Software.
 * Licensed under CANN Open Software License Agreement Version 1.0 (the "License").
 * Please refer to the License for details. You may not use this file except in compliance with the License.
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
 * See LICENSE in the root of the software repository for the full text of the License.
 * ===================================================================================================================*/

#ifndef AIR_CXX_TESTS_UT_GE_RUNTIME_V2_FAKER_ALLOCATOR_FACKER_H_
#define AIR_CXX_TESTS_UT_GE_RUNTIME_V2_FAKER_ALLOCATOR_FACKER_H_

#include <vector>
#include "ge/ge_allocator.h"
#include "exe_graph/runtime/gert_mem_block.h"
#include "exe_graph/runtime/gert_mem_allocator.h"
namespace gert {
class GertMemBlockFaker : public GertMemBlock {
  public:
  explicit GertMemBlockFaker(void *addr) : addr_(addr) {}
  ~GertMemBlockFaker() override {
      addr_ = nullptr;
  };
  void Free(int64_t stream_id) override {
    free(addr_);
    addr_ = nullptr;
  }
  void *GetAddr() override { return addr_; }
  private:
  void *addr_;
};
class AllocatorFaker : public GertAllocator {
 public:
  AllocatorFaker() = default;
  ~AllocatorFaker() override;
  GertMemBlock *Malloc(size_t size) override;
  void Free(GertMemBlock *block) override;

  GertTensorData MallocTensorData(size_t size) override {
    return GertTensorData();
  }
  TensorData MallocTensorDataFromL1(size_t size) override {
    return TensorData();
  }
  ge::graphStatus ShareFromTensorData(const TensorData &td, GertTensorData &gtd) override {
    return 0;
  }
  ge::graphStatus SetL1Allocator(ge::Allocator *allocator) override {
    return ge::GRAPH_SUCCESS;
  }
  ge::graphStatus FreeAt(int64_t stream_id, GertMemBlock *block) override {
    return ge::GRAPH_SUCCESS;
  }
  int64_t GetStreamNum() override {
    return 0;
  }
 private:
  std::vector<GertMemBlock *> block_pool_;
};
}
#endif
